module.exports = app => {
  const { STRING, INTEGER, TEXT, DATE } = app.Sequelize;

  const News = app.model.define('news', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    title: { type: STRING(100), allowNull: false, comment: '标题' },
    description: { type: STRING(255), comment: '描述' },
    content: { type: TEXT, comment: '内容' },
    imageUrl: { type: STRING(255), comment: '封面图片URL' },
    author: { type: STRING(50), comment: '作者' },
    publishTime: { type: DATE, comment: '发布时间' },
    views: { type: INTEGER, defaultValue: 0, comment: '浏览量' },
    status: { type: INTEGER, defaultValue: 1, comment: '状态：0-草稿，1-已发布' },
    createdAt: DATE,
    updatedAt: DATE,
  });

  return News;
};
